package net.lanelife.casino.cms.web.controller;

import javax.servlet.ServletRequest;

import net.lanelife.casino.caipiao.dto.admin.PaymentBankCreateDTO;
import net.lanelife.casino.caipiao.dto.admin.PaymentBankDTO;
import net.lanelife.casino.caipiao.dto.admin.PaymentBankTable;
import net.lanelife.casino.caipiao.dto.admin.PaymentBankUpdateDTO;
import net.lanelife.casino.caipiao.entity.PaymentBank;
import net.lanelife.casino.caipiao.service.api.IBankService;
import net.lanelife.casino.caipiao.service.api.IPaymentBankService;
import net.lanelife.casino.caipiao.service.api.IPaymentPlatformService;
import net.lanelife.casino.cms.web.controller.support.CRUDController;
import net.lanelife.casino.common.service.support.IGenericService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value = PaymentBankController.PATH)
public class PaymentBankController extends CRUDController<PaymentBank, Integer, PaymentBankDTO, PaymentBankCreateDTO, PaymentBankUpdateDTO, PaymentBankTable<PaymentBankDTO>> {
	
	public static final String PATH = "/payment-bank";
	
	public PaymentBankController() {
		super(PATH);
	}

	@Autowired
	private IPaymentBankService paymentBankService;
	
	@Autowired
	private IPaymentPlatformService paymentPlatformService;
	
	@Autowired
	private IBankService bankService;
	
	@Override
	protected IGenericService<PaymentBank, Integer> getService() {
		return paymentBankService;
	}
	
	@Override
	protected void preList(Model model, ServletRequest request) throws Exception {
		model.addAttribute("paymentPlatformList", paymentPlatformService.findAll());
	}

	@Override
	protected void preCreate(Model model, PaymentBankCreateDTO createDTO) throws Exception {
		model.addAttribute("paymentPlatformList", paymentPlatformService.findAll());
		model.addAttribute("bankList", bankService.findAll());
	}

	@Override
	protected void preUpdate(Model model, PaymentBankUpdateDTO updateDTO) throws Exception {
		model.addAttribute("paymentPlatformList", paymentPlatformService.findAll());
		model.addAttribute("bankList", bankService.findAll());
	}
	
	

}
